def model_name(model, key):
    dict = {"bbs":{"title":"标题", 'content': '内容', 'type': '板块'},}
    try:
        return dict[model][key]
    except:
        return key

class Tools:
    @staticmethod
    def format_errors(model, errors):
        message = []
        for key in errors:
            message.append(model_name(model, key) + "：" + errors[key][0])
        return '<br>'.join(message)

    @staticmethod
    def paginator(page, list):
        # page 当前页码数; list 初始化之后的集合
        page_size = 3
        right, left = [], []
        for i in range(page_size):
            cur_left = page - i - 1
            if cur_left > 0:
                left.append(cur_left)
            cur_right = page + i + 1
            if cur_right <= list.num_pages:
                right.append(cur_right)
        left.sort()
        return {"left" : left, "right" : right }